/*
 * BoardElements.cpp
 *
 *  Created on: 13/06/2014
 *      Author: lucio
 */

#include "BoardElements.h"

void BoardElements::UnToggle(bool tg1, bool tg2, bool tg3, bool tg4,
		bool tg5, bool tg6) {
	BackgroundButton->set_active(tg1);
	BoxButton->set_active(tg2);
	MetalBoxButton->set_active(tg3);
	PlayerSpawnButton->set_active(tg4);
	ZombieSpawnButton->set_active(tg5);
	PlantButton->set_active(tg6);
}

void BoardElements::Background_Toggle(){
	if(BackgroundButton->get_active()){
		UnToggle(true,false,false,false,false,false);
	}
}

void BoardElements::Box_Toggle(){
	if(BoxButton->get_active()){
		UnToggle(false,true,false,false,false,false);
	}
}

void BoardElements::MetalBox_Toggle(){
	if(MetalBoxButton->get_active()){
		UnToggle(false,false,true,false,false,false);
	}
}

void BoardElements::PlayerSpawn_Toggle(){
	if(PlayerSpawnButton->get_active()){
		UnToggle(false,false,false,true,false,false);
	}
}

void BoardElements::ZombieSpawn_Toggle(){
	if(ZombieSpawnButton->get_active()){
		UnToggle(false,false,false,false,true,false);
	}
}

void BoardElements::Plant_Toggle(){
	if(PlantButton->get_active()){
		UnToggle(false,false,false,false,false,true);
	}
}

BoardElements::BoardElements(Glib::RefPtr<Gtk::Builder>& builder, Board* board) {
	this->board = board;
	builder->get_widget("BackgroundButton",this->BackgroundButton);
	builder->get_widget("BoxButton",this->BoxButton);
	builder->get_widget("MetalBoxButton",this->MetalBoxButton);
	builder->get_widget("PlayerSpawnButton",this->PlayerSpawnButton);
	builder->get_widget("ZombieSpawnButton",this->ZombieSpawnButton);
	builder->get_widget("PlantButton",this->PlantButton);

	BackgroundButton->signal_toggled().connect
			(sigc::mem_fun(*this, &BoardElements::Background_Toggle));
	BoxButton->signal_toggled().connect
				(sigc::mem_fun(*this, &BoardElements::Box_Toggle));
	MetalBoxButton->signal_toggled().connect
				(sigc::mem_fun(*this, &BoardElements::MetalBox_Toggle));
	PlayerSpawnButton->signal_toggled().connect
				(sigc::mem_fun(*this, &BoardElements::PlayerSpawn_Toggle));
	ZombieSpawnButton->signal_toggled().connect
				(sigc::mem_fun(*this, &BoardElements::ZombieSpawn_Toggle));
	PlantButton->signal_toggled().connect
				(sigc::mem_fun(*this, &BoardElements::Plant_Toggle));

}

BoardElements::~BoardElements() {
	// TODO Auto-generated destructor stub
}

